<template>
	<view class="motionDetail">
		<view class="header">
			<view class="left" @click="handleBack">
				<u-icon name="arrow-left" :size="50"></u-icon>
			</view>
			<view class="center">{{ motionName }}</view>
			<view class="right"></view>
		</view>
		
		
		<view class="content">
			<view class="motion_img">
				<video
					:src="baseUrl + detailData.videoUrl" 
				></video>
			</view>
			<view v-html="detailData.prescriptionDetails"></view>
			
			<view class="add" @click="addMyMotionList">
				<image src="@/static/img/home/jia.png" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	import { motionDetail } from '../../service/api.js'
	export default {
		data() {
			return {
				baseUrl: this.$BASEImageUrl,
				detailData: {},
				motionName: ""
			}
		},
		onLoad(options) {
			this.motionName = options.name;
			this.getDetail(options.id);
		},
		methods: {
			getDetail(id) {
				motionDetail(id).then(res => {
					if(res.status == 200) {
						this.detailData = res.data;
						
						this.$set(this.detailData , "montionName", this.motionName)
					}
				})
			},
			handleBack() {
				uni.switchTab({
					url: "/pages/motion/motion"
				})
			},
			addMyMotionList() {
				this.$store.dispatch("addCartAction", this.detailData);
			}
		}
	}
</script>

<style scoped lang="scss">

.motionDetail {
	position: relative;
	overflow: hidden;
	height: 100vh;
	.header {
		width: 100%;
		height: 65px;
		background-color: #fff;
		display: flex;
		align-items: center;
		margin-top: 10px;
		.center {
			flex: 1;
			text-align: center;
			font-size: 18px;
			
		}
		.left, .right {
			width: 27px;
			// height: 100%;
			margin-left: 14px;
		}
	}
	.content {
			padding: 0 20px;
		.motion_img {
			width: 100%;
			height: 300px;
			background-color: #2BC3A4;
			margin-bottom: 20px;
			overflow: hidden;
			border-radius: $uni-border-radius-16;
			video {
				width: 100%;
				height: 100%;
			}
		}
		.add {
			position: absolute;
			right: 20px;
			bottom: 40px;
			width: 60px;
			height: 60px;
			image {
				width: 100%;
				height: 100%;
			}
		}
	}
}

</style>
